This section describes the UnsignedFixMulDiv function provided by the Sound Manager that you can use to perform multiplication and division on unsigned fixed-point numbers.
You can use the UnsignedFixMulDiv function to perform multiplications and divisions on unsigned fixed-point numbers. You'll typically use it to calculate sample rates.
FUNCTION UnsignedFixMulDiv (value: UnsignedFixed;
multiplier: UnsignedFixed;
divisor: UnsignedFixed):
UnsignedFixed;
The UnsignedFixMulDiv function returns the fixed-point number that is the value of the value parameter, multiplied by the value in the multiplier parameter and divided by the value in the divisor parameter. Note that UnsignedFixMulDiv performs both operations before returning. If you want to perform only a multiplication or only a division, pass the value $00010000 for whichever parameter you want to ignore. For example, to determine the sample rate that is twice that of the 22 kHz rate, you can use UnsignedFixMulDiv as follows:
myNewRate := UnsignedFixMulDiv(rate22kHz, $00020000, $00010000);
Similarly, to determine the sample rate that is half that of the 44 kHz rate, you can use UnsignedFixMulDiv as follows:
myNewRate := UnsignedFixMulDiv(rate44kHz, $00010000, $00020000);
| Previous | Chapter contents | Chapter top | Section top | Next |